package com.asia5b.a5mall.goods.adapter

import androidx.recyclerview.widget.RecyclerView
import android.widget.LinearLayout
import android.widget.TextView
import com.asia5b.a5mall.goods.R
import com.asia5b.a5mall.goods.activity.SearchGoodsActivity
import com.asia5b.a5mall.middleware.model.goods.SelectorBean
import com.asia5b.a5mall.middleware.model.goods.SelectorKeyBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * Created by zhangyuncai on 2020/5/13.
 */
class GoodsSelectorValueAdapter(var selectorKeyBean: SelectorKeyBean, list: ArrayList<SelectorBean>, var tv_goodsselector_selectortext: TextView) :
        BaseQuickAdapter<SelectorBean, BaseViewHolder>(R.layout.item_goodsseletor_value_adapter, list) {

    override fun convert(helper: BaseViewHolder, item: SelectorBean) {
        helper.setText(R.id.tv_goodsselector_value, item.name)
        val ll_goodsselector_value = helper.getView<LinearLayout>(R.id.ll_goodsselector_value)
        ll_goodsselector_value.isSelected = item == selectorKeyBean.selectItem
    }

    override fun getItemCount(): Int {
        if (selectorKeyBean.isSingleLine && data.size > 3) {
            return 3
        }
        return super.getItemCount()
    }
}